#!/bin/bash

# 定义下载目录
DOWNLOAD_DIR="./llm_gguf"

# 显示菜单
echo "请选择一个选项 (1-9):"
echo "1. 下载 向量化模型 Qwen3-Embedding-0.6B-Q8_0.gguf 模型到 $DOWNLOAD_DIR 目录" # 639.15MB
# https://modelscope.cn/models/Qwen/Qwen3-Embedding-0.6B-GGUF/resolve/master/Qwen3-Embedding-0.6B-Q8_0.gguf
echo "2. 下载 向量化模型 Qwen3-Embedding-8B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录" # 5.42GB
# https://modelscope.cn/models/Qwen/Qwen3-Embedding-8B-GGUF/resolve/master/Qwen3-Embedding-8B-Q5_K_M.gguf
echo "3. 下载 向量化模型 Qwen3-Embedding-8B-Q8_0.gguf 模型到 $DOWNLOAD_DIR 目录" # 8.05GB
# https://modelscope.cn/models/Qwen/Qwen3-Embedding-8B-GGUF/resolve/master/Qwen3-Embedding-8B-Q8_0.gguf
echo "4. 下载 重排模型 Qwen3-Reranker-0.6B-q8_0.gguf 模型到 $DOWNLOAD_DIR 目录" # 639.15MB
# https://modelscope.cn/models/dengcao/Qwen3-Reranker-0.6B-GGUF/resolve/master/Qwen3-Reranker-0.6B-q8_0.gguf
echo "5. 下载 重排模型 Qwen3-Reranker-4B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录" # 5.95GB
# https://modelscope.cn/models/dengcao/Qwen3-Reranker-8B-GGUF/resolve/master/Qwen3-Reranker-8B-q5_k_m.gguf
echo "6. 下载 重排模型 Qwen3-Reranker-8B-q8_0.gguf 模型到 $DOWNLOAD_DIR 目录" # 8.71GB
# https://modelscope.cn/models/dengcao/Qwen3-Reranker-8B-GGUF/resolve/master/Qwen3-Reranker-8B-q8_0.gguf
echo "7. 下载 大语言模型 Qwen3-0.6B-Q8_0.gguf 模型到 $DOWNLOAD_DIR 目录" # 639.45MB
# https://modelscope.cn/models/Qwen/Qwen3-0.6B-GGUF/resolve/master/Qwen3-0.6B-Q8_0.gguf
echo "8. 下载 大语言模型 Qwen2.5-7B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录" # 5.44GB
# https://modelscope.cn/models/Qwen/Qwen2.5-7B-Instruct-GGUF/resolve/master/qwen2.5-7b-instruct-q5_k_m.gguf
echo "9. 预留选项"

# 读取用户输入
read -p "请输入你的选择: " choice

# 检查输入是否为1-9的数字
if ! [[ "$choice" =~ ^[1-9]$ ]]; then
    echo "错误: 请输入1到9之间的数字"
    exit 1
fi

# 根据选择执行相应操作
case $choice in
    1)
        echo "开始下载 Qwen3-Embedding-0.6B-Q8_K_M.gguf 模型到 $DOWNLOAD_DIR 目录..."
        wget -c "https://modelscope.cn/models/Qwen/Qwen3-Embedding-0.6B-GGUF/resolve/master/Qwen3-Embedding-0.6B-Q8_0.gguf" -O Qwen3-Embedding-0.6B-Q8_0.gguf -P "$DOWNLOAD_DIR"
        if [ $? -eq 0 ]; then
            echo "下载完成，文件保存到: $DOWNLOAD_DIR"
        else
            echo "下载中断或失败"
        fi
        ;;
    2)
        echo "开始下载 Qwen3-Embedding-8B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录..."
        wget -c "https://modelscope.cn/models/Qwen/Qwen3-Embedding-8B-GGUF/resolve/master/Qwen3-Embedding-8B-Q5_K_M.gguf" -O Qwen3-Embedding-8B-Q5_K_M.gguf -P "$DOWNLOAD_DIR"
        if [ $? -eq 0 ]; then
            echo "下载完成，文件保存到: $DOWNLOAD_DIR"
        else
            echo "下载中断或失败"
        fi
        ;;
    3)
        echo "开始下载 Qwen3-Reranker-0.6B-Q8_K_M.gguf 模型到 $DOWNLOAD_DIR 目录..."
        wget -c "" -O  -P "$DOWNLOAD_DIR"
        if [ $? -eq 0 ]; then
            echo "下载完成，文件保存到: $DOWNLOAD_DIR"
        else
            echo "下载中断或失败"
        fi
        ;;
    4)
        echo "开始下载 Qwen3-Reranker-4B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录..."
        wget -c "" -O  -P "$DOWNLOAD_DIR"
        if [ $? -eq 0 ]; then
            echo "下载完成，文件保存到: $DOWNLOAD_DIR"
        else
            echo "下载中断或失败"
        fi
        ;;
    5)
        echo "开始下载 Qwen2.5-7B-Q5_K_M.gguf 模型到 $DOWNLOAD_DIR 目录..."
        wget -c "" -O  -P "$DOWNLOAD_DIR"
        if [ $? -eq 0 ]; then
            echo "下载完成，文件保存到: $DOWNLOAD_DIR"
        else
            echo "下载中断或失败"
        fi
        ;;
    *)
        echo "你选择了 $choice，该选项尚未实现"
        ;;
esac
